package gatperdut.chato.core.item;

import gatperdut.chato.model.Chato.Item.Food;

public class FoodController extends AmountController {

    public FoodController( Food food ) {
        super( food );
    }

    public boolean canAffordPortionIncrease( int increase ) {
        return getAmount().getPortion() + increase <= getAmount().getMaxPortion();
    }

    public int getPortionLeftToMax() {
        return getAmount().getMaxPortion() - getAmount().getPortion();
    }

    public boolean canAffordPortionDecrease( int decrease ) {
        return getAmount().getPortion() - decrease >= 0;
    }

    public void addPortion( int portion ) {
        getAmount().setPortion( getAmount().getPortion() + portion );
    }

    public void consumePortion( int portion ) {
        getAmount().setPortion( getAmount().getPortion() - portion );
    }

    public boolean hasNoPortionLeft() {
        return getAmount().getPortion() <= 0;
    }

    public boolean hasWholePortion() {
        return getAmount().getPortion() >= getAmount().getMaxPortion();
    }

    public void setToMaxPortion() {
        getAmount().setPortion( getAmount().getMaxPortion() );
    }

    @Override
    public Food getAmount() {
        return (Food) super.getAmount();
    }

    public int getPortion() {
        return getAmount().getPortion();
    }

    public int getMaxPortion() {
        return getAmount().getMaxPortion();
    }

    public void setMaxPortion( int maxPortion ) {
        getAmount().setMaxPortion( maxPortion );
    }

    public void setPortion( int portion ) {
        getAmount().setPortion( portion );
    }

    public float getPortionRatio() {
        return (float) getPortion() / (float) getMaxPortion();
    }

}
